GBML manual / Camera

camera_bounds

Clamps every eased/set camera position into this rectangle (where the view may begin: typically from the room’s top-left corner (0, 0) to (room_width() - screen_width(), room_height() - screen_height()), so the screen never shows past an edge). A room’s own load sets this automatically.

Works differently on Game Boy - The camera on the Game Boy always stays inside the room's picture, so the limits you set are not used.

Works differently on Game Boy Color - The camera on the Game Boy Color always stays inside the room's picture, so the limits you set are not used.

On other consoles this differs: see Side by side and How the consoles differ.

Syntax

camera_bounds(left, top, right, bottom)

Arguments

NameType
leftreal
topreal
rightreal
bottomreal

Returns

Nothing.

Description

Clamps every eased or set camera position into this rectangle - left, top, right, bottom. Like camera_set, these numbers count where the camera's view begins (its top-left corner), as places in the room counted from the room's top-left corner. So left and top are the furthest left and up the view may begin, and right and bottom are the furthest right and down. A room's own load already sets this automatically from its size (pulled in by a whole screen at the right and bottom, so the camera never shows past an edge) - call this yourself only to override that default, e.g. to keep the camera from ever revealing a not-yet-relevant part of a room.

Example

camera_bounds(0, 0, room_width() - screen_width(), room_height() - screen_height());

Keeps the screen inside the room. The view may begin as far left and up as the room's top-left corner (0, 0), and as far right and down as room_width() - screen_width() and room_height() - screen_height(), because a view that begins any later would run past the room's far edges. A starting point for narrowing further (a boss-arena room that should never scroll past its own arena, say).

On the GBA

A room's own load sets this automatically.

See also: camera_bounds_clear